﻿#include "InstructionTurnTablePowerOff.h"

#include "ScriptRunner.h"
#include "TurnTableCodec.h"
#include "StateChecker.h"
#include "Device.h"

__SCRIPTINSTRUCTION_REGISTER(InstructionTurnTablePowerOff,ScriptInstruction::Instruction_TurnTable_PowerOff,&InstructionTurnTablePowerOff::fromByteArray1);

InstructionTurnTablePowerOff::InstructionTurnTablePowerOff()
{
  instructionFlag = Instruction_TurnTable_PowerOff;
}

InstructionTurnTablePowerOff::InstructionTurnTablePowerOff(InstructionTurnTablePowerOff const& instructionTurnTablePowerOff)
{
  *this=instructionTurnTablePowerOff;
}

InstructionTurnTablePowerOff& InstructionTurnTablePowerOff::operator=(InstructionTurnTablePowerOff const & instructionTurnTablePowerOff)
{
  *(ScriptInstruction*)this=instructionTurnTablePowerOff;
  return *this;
}

InstructionTurnTablePowerOff::~InstructionTurnTablePowerOff()
{}

void InstructionTurnTablePowerOff::run()
{
  scriptRunner->sendInstruction(deviceId,TurnTableCodec::TurnTable_PowerOff);
  StateChecker<bool>::next_ifConditionReached(&Device::getTurnTable_runningState_power,
                                              false,
                                              deviceId,
                                              scriptRunner);
}

QString InstructionTurnTablePowerOff::toString()
{
  return QStringLiteral("转台下电");
}

QByteArray InstructionTurnTablePowerOff::toByteArray()
{
  return ScriptInstruction::toByteArray();
}

ScriptInstruction* InstructionTurnTablePowerOff::fromByteArray1(char * const src,int size,int * offset)
{
  (void)src;
  (void)size;
  (void)offset;
  return new InstructionTurnTablePowerOff();
}
